package itheima.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Value("${person.name}")
    private String name;
    @Value("${address[1]}")
    private String address;

    @Autowired
    private Environment evn;

    @RequestMapping("/hello")
    public String hello(){
        System.out.println(name);
        System.out.println(address);
        return "hello spring boot";
    }

    @RequestMapping("/hello2")
    public String hello2(){
        System.out.println(evn.getProperty("person.name"));
        System.out.println(evn.getProperty("address[1]"));
        return "hello spring boot2";
    }
}
